package com.aode.common.bean.response;

import android.os.Parcel;
import android.os.Parcelable;
import android.widget.ImageView;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
import androidx.databinding.BindingAdapter;

import com.aode.common.url.UrlGather;
import com.bumptech.glide.Glide;

import java.util.ArrayList;
import java.util.List;

public class News extends BaseObservable implements Parcelable {
    private String fromUserNam;
    private String fromUserAvatar;
    private String toUserName;
    private String toUserAvatar;
    @BindingAdapter({"useravatar"})
    public static void loadImage(ImageView imageView, String imageUrl){
        Glide.with(imageView.getContext()).load(UrlGather.BASE_URL+imageUrl).into(imageView);
    }
    private ArrayList<Boolean> isSend;
    private ArrayList<String> content;
    private String date;


    public News(){

    }

    protected News(Parcel in) {
        fromUserNam = in.readString();
        fromUserAvatar = in.readString();
        toUserName = in.readString();
        toUserAvatar = in.readString();
        date = in.readString();
        isSend = in.readArrayList(ClassLoader.getSystemClassLoader());
        content = in.readArrayList(ClassLoader.getSystemClassLoader());
    }

    public static final Creator<News> CREATOR = new Creator<News>() {
        @Override
        public News createFromParcel(Parcel in) {
            return new News(in);
        }

        @Override
        public News[] newArray(int size) {
            return new News[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(fromUserNam);
        dest.writeString(fromUserAvatar);
        dest.writeString(toUserName);
        dest.writeString(toUserAvatar);
        dest.writeString(date);
        dest.writeList(isSend);
        dest.writeList(content);
    }

    @Bindable
    public String getFromUserNam() {
        return fromUserNam;
    }

    public void setFromUserNam(String fromUserNam) {
        this.fromUserNam = fromUserNam;
    }
    @Bindable
    public String getFromUserAvatar() {
        return fromUserAvatar;
    }

    public void setFromUserAvatar(String fromUserAvatar) {
        this.fromUserAvatar = fromUserAvatar;
    }
    @Bindable
    public String getToUserName() {
        return toUserName;
    }

    public void setToUserName(String toUserName) {
        this.toUserName = toUserName;
    }
    @Bindable
    public String getToUserAvatar() {
        return toUserAvatar;
    }

    public void setToUserAvatar(String toUserAvatar) {
        this.toUserAvatar = toUserAvatar;
    }

    public ArrayList<Boolean> getIsSend() {
        return isSend;
    }

    public void setIsSend(ArrayList<Boolean> isSend) {
        this.isSend = isSend;
    }

    @Bindable
    public ArrayList<String> getContent() {
        return content;
    }

    public void setContent(ArrayList<String> content) {
        this.content = content;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public static Creator<News> getCREATOR() {
        return CREATOR;
    }

    @Override
    public String toString() {
        return "News{" +
                "fromUserNam='" + fromUserNam + '\'' +
                ", fromUserAvatar='" + fromUserAvatar + '\'' +
                ", toUserName='" + toUserName + '\'' +
                ", toUserAvatar='" + toUserAvatar + '\'' +
                ", isSend=" + isSend +
                ", content=" + content +
                ", date='" + date + '\'' +
                '}';
    }
}
